<template>
    <div class="hz-container">
        <div class="hz-content" id="01">
            <div class="hz-content-left hz-box-img" v-if="imgArr.length > 0">
                <img :src="imgArr[0].image_url" alt="" class="hz-img">
            </div>
            <div class="hz-content-right hz-box-desc">
                <h2>购买</h2>
                <p>
                    提供1-3年的整机保修和终身软件维护和升级；<br>
                    提供免费的运输和安装调试；<br>
                    提供7*24小时电话支持；<br>
                    提供上门服务；<br>
                    提供现场运营培训和指导；<br>
                </p>
                <div>
                    <el-button @click="$router.push({ name: 'lxwm'})">联系我们</el-button>
                </div>
            </div>
        </div>
        <template v-if="screenWidth > 768">
            <div class="hz-content02">
                <div class="hz-content02-item" v-if="imgArr1.length > 0"
                    :style="{ backgroundImage: `url(${imgArr1[0].image_url})` }">
                    <div class="hz-content-left hz-box-desc ">
                        <h2>合作经营</h2>
                        <p>
                            我司提供全套产品和内容制作以及现场运<br>
                            营，同博物馆、科技馆、景区以及第三方公<br>
                            司合作语音导览项目，所得收入分成。<br>
                        </p>
                        <el-button @click="$router.push({ name: 'lxwm'})">联系我们</el-button>
                    </div>
                    <div class="hz-content-right hz-box-img box-768" v-if="imgArr2.length > 0">
                        <div class="hz-img"></div>
                    </div>
                </div>
            </div>
        </template>
        <template v-else-if="screenWidth <= 768">
            <div class="hz-content02" v-if="imgArr1.length > 0"
                :style="{ backgroundImage: `url(${imgArr1[0].image_url})` }">
                <div class="hz-content02-item">
                    <div class="hz-content-left hz-box-desc ">
                        <h2>合作经营</h2>
                        <p>
                            我司提供全套产品和内容制作以及现场运<br>
                            营，同博物馆、科技馆、景区以及第三方公<br>
                            司合作语音导览项目，所得收入分成。<br>
                        </p>
                        <el-button @click="$router.push({ name: 'lxwm'})">联系我们</el-button>
                    </div>
                </div>
            </div>
        </template>
        <div class="hz-content" id="02">
            <div class="hz-content-left hz-box-desc">
                <h2>授权代理</h2>
                <p>
                    公司面向中国区域各省发展独家授权代理<br>
                    商，提供全套产品和技术支持，制定统一<br>
                    的售价和质量服务标准，各省代理商在公<br>
                    司官网显示，负责本省市场拓展。<br>
                    欢迎来电洽谈！<br>
                </p>
                <el-button @click="$router.push({ name: 'lxwm'})">联系我们</el-button>
            </div>
            <div class="hz-content-right hz-box-img box-768" v-if="imgArr1.length > 0">
                <img :src="imgArr3[0].image_url" alt="" class="hz-img">
            </div>
        </div>
        <div class="hz-content" id="03">
            <div class="hz-content-left hz-box-img" v-if="imgArr2.length > 0">
                <img :src="imgArr3[0].image_url" alt="" class="hz-img">
            </div>
            <div class="hz-content-right hz-box-desc">
                <h2>短期租赁</h2>
                <p>
                    对于短期临展，我公司提供设备租赁服务，<br>
                    包括设备运输、安装调试、内容制作和现场<br>
                    运营，以及展览结束提供观众人数、展品<br>
                    受欢迎排名等相关展览数据。<br>
                </p>
                <el-button @click="$router.push({ name: 'lxwm'})">联系我们</el-button>
            </div>
        </div>
    </div>
</template>

<script setup>
import { ref, onMounted } from 'vue';
import { getHzList } from '@/api/rjxt'


const imgArr = ref([])
const imgArr1 = ref([])
const imgArr2 = ref([])
const imgArr3 = ref([])

// 响应式数据，用于存储屏幕宽度
const screenWidth = ref(window.innerWidth);

// 监听屏幕尺寸变化，更新屏幕宽度数据
const updateScreenWidth = () => {
    screenWidth.value = window.innerWidth;
};
window.addEventListener('resize', updateScreenWidth);

onMounted(() => {
    getHzList().then(res => {
        imgArr.value = res.data.filter(item => item.position === 'content_01')
        imgArr1.value = res.data.filter(item => item.position === 'content_02')
        imgArr2.value = res.data.filter(item => item.position === 'content_03')
        imgArr3.value = res.data.filter(item => item.position === 'content_04')
    })
})

</script>

<style scoped>
/* 媒体查询 手机 */
@media screen and (max-width: 768px) {
    .box-768 {
        margin-top: 30px;
    }

    :deep(.el-button) {
        border-radius: 0;
        margin-left: 1.5em;
        width: 120px;
        height: 40px;
        border: 1px solid #000;
        margin-top: 10px;
    }

    :deep(.el-button:hover) {
        background-color: #409eff;
        color: #fff;
    }

    .hz-container {
        padding: 0 100px;
    }

    .hz-content02 {
        margin-bottom: 50px;
        background-repeat: no-repeat;
        background-size: 100%;
    }

    .hz-content02-item {
        display: flex;
        flex-direction: column;
        flex-wrap: nowrap;
        align-content: center;
        justify-content: center;
        align-items: center;
        height: 300px;
        max-width: 768px;
        min-width: 500px;
    }

    .hz-box-desc {
        display: flex;
        background-color: #fff;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        align-content: center;
        padding: 0 20px;
        height: 240px;

        h2 {
            font-size: 30px;
        }

        p {
            font-size: 17px;
            line-height: 2;
        }
    }

    .hz-box-img {
        width: 350px;
    }

    .hz-img {
        max-width: 100%;
        height: auto;
    }

    .hz-container {
        display: flex;
        flex-direction: column;
        align-content: center;
        justify-content: center;
        align-items: center;
        width: 100%;
    }

    .hz-content {
        display: flex;
        margin-bottom: 100px;
        flex-direction: column;
        flex-wrap: nowrap;
        align-content: center;
        justify-content: center;
        align-items: center;
    }

    .hz-content-right {
        display: flex;
        flex-direction: column;
        flex-wrap: nowrap;
        align-content: center;
        justify-content: center;
        align-items: flex-start;
        margin-top: 50px;
    }
}

/* 媒体查询 平板 */
@media screen and (min-width: 769px) and (max-width: 1024px) {
    .hz-container {
        padding: 0 100px;
    }

    .hz-content02 {
        margin-bottom: 100px;
    }

    .hz-content02-item {
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        align-content: center;
        justify-content: center;
        align-items: center;
        height: 300px;
        background-repeat: no-repeat;
        background-size: 100%;
    }

    .hz-content-right {
        margin-left: 50px;
    }

    :deep(.el-button) {
        border-radius: 0;
        width: 120px;
        height: 40px;
        border: 1px solid #000;
        margin-top: 20px;
    }

    :deep(.el-button:hover) {
        background-color: #409eff;
        color: #fff;
    }

    .hz-box-desc {
        display: flex;
        background-color: #fff;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        align-content: center;
        padding: 0 20px;
        height: 240px;

        h2 {
            font-size: 30px;
            letter-spacing: 0.2em;
        }

        p {
            font-size: 17px;
            margin-top: 10px;
            line-height: 1.75;
        }
    }

    .hz-box-img {
        width: 370px;
    }

    .hz-img {
        max-width: 100%;
        height: auto;
    }

    .hz-container {
        display: flex;
        flex-direction: column;
        align-content: center;
        justify-content: center;
        align-items: center;
        width: 100%;
        margin-top: 20px;
    }

    .hz-content {
        display: flex;
        margin-bottom: 100px;
    }
}

/* 媒体查询 电脑 */
@media screen and (min-width: 1025px) {
    .hz-container {
        padding: 0 150px;
    }

    .hz-content02 {
        margin-bottom: 100px;
    }

    .hz-content02-item {
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        align-content: center;
        justify-content: center;
        align-items: center;
        height: 400px;
        background-repeat: no-repeat;
        background-size: 100%;
    }

    .hz-content-right {
        margin-left: 150px;
    }

    :deep(.el-button) {
        border-radius: 0;
        width: 120px;
        height: 40px;
        border: 1px solid #000;
        margin: 20px auto;
    }

    :deep(.el-button:hover) {
        background-color: #409eff;
        color: #fff;
    }

    .hz-box-desc {
        display: flex;
        background-color: #fff;
        width: 30vw;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        align-content: center;
        padding: 0 20px;

        h2 {
            font-size: 40px;
            line-height: 2;
            letter-spacing: 0.2em;
        }

        p {
            font-size: 18px;
            line-height: 2;
        }
    }

    .hz-box-img {
        width: 565px;
        height: 452px;
    }

    .hz-img {
        max-width: 100%;
        height: auto;
    }

    .hz-container {
        display: flex;
        flex-direction: column;
        align-content: center;
        justify-content: center;
        align-items: center;
        width: 100%;
    }

    .hz-content {
        display: flex;
        margin-bottom: 100px;
    }
}
</style>
